﻿<!DOCTYPE html>
<!--承包商人员名录管理编辑-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>

    <style>
        .el-dialog__body {
            height: 100% !important;
        }

        .el-dialog.is-fullscreen {
            overflow: hidden !important;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak class="popupW100">
        <el-form :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="100px" size="mini"
                 label-position="right">

            <el-row>
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item prop="cbs_user.personnelName">
                            <el-input type="text" v-model="Form.cbs_user.personnelName" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{ContractorPersonnelDirectory.PersonnelName+mark.m}}
                                </template>
                            </el-input>
                            <span class="iputLineMust" v-if="!Form.cbs_user.personnelName">
                                <!-- 必填项添加 -->
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="11" :offset="2">
                    <div class="elst-select-mini">
                        <el-form-item prop="cbs_user.cbsListId">
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{ContractorPersonnelDirectory.ContractorName+mark.m}}
                                </template>
                                <el-select @visible-change="visibleChange" v-model="Form.cbs_user.cbsListId" slot="suffix"
                                           :placeholder="ContractorPersonnelDirectory.ContractorName">
                                    <el-option label="请选择" value=""></el-option>
                                    <el-option v-for="item in CBS_List" :label="item.contractorName" :value="item.id">
                                    </el-option>
                                </el-select>
                            </el-input>
                            <span class="iputLineMust" v-if="!Form.cbs_user.cbsListId">
                               <!--必填项添加-->
                               <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>
                <!--<el-col :span="1" :offset="1">
                    <el-button type="primary" @click="ContractorInput('tj')">{{col.Choose}}</el-button>
                </el-col>-->
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item prop="cbs_user.sex">
                            <el-input size="mini">
                                <template slot="prepend">
                                    <div> {{ContractorPersonnelDirectory.sex+mark.m}}</div>
                                </template>
                                <el-select @visible-change="visibleChange" v-model="Form.cbs_user.sex" slot="suffix"
                                           :placeholder="ContractorPersonnelDirectory.sex">
                                    <el-option label="请选择" value=""></el-option>
                                    <el-option v-for="item in sex" :label="item.value" :value="item.key">
                                    </el-option>
                                </el-select>
                            </el-input>
                            <span class="iputLineMust" v-if="!Form.cbs_user.sex">
                                <!-- 必填项添加 -->
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>

                <el-col :span="11" :offset="2">
                    <div class="elst-select-mini">
                        <el-form-item prop="cbs_user.birther">
                            <div class="elst-select-mini">
                                <el-input size="mini">
                                    <template slot="prepend">
                                        {{ContractorPersonnelDirectory.YearMonth+mark.m}}
                                    </template>
                                    <el-date-picker slot="suffix" v-model="Form.cbs_user.birther" type="date" size="mini"
                                                    format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择时间">
                                    </el-date-picker>
                                </el-input>
                            </div>
                            <span class="iputLineMust" v-if="!Form.cbs_user.birther">
                                <!-- 必填项添加 -->
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item prop="cbs_user.idNumber">
                            <el-input type="text" v-model="Form.cbs_user.idNumber" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{ContractorPersonnelDirectory.IDNumber+mark.m}}
                                </template>
                            </el-input>
                            <span class="iputLineMust" v-if="!Form.cbs_user.idNumber">
                                <!-- 必填项添加 -->
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="11" :offset="2">
                    <div class="elst-select-mini">
                        <el-form-item prop="cbs_user.phone">
                            <el-input type="text" v-model="Form.cbs_user.phone" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{ContractorPersonnelDirectory.phone+mark.m}}
                                </template>
                            </el-input>
                            <span class="iputLineMust" v-if="!Form.cbs_user.phone">
                                <!-- 必填项添加 -->
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item prop="cbs_user.constructionCategory">
                            <el-input size="mini">
                                <template slot="prepend">
                                    <div> {{ContractorPersonnelDirectory.ConstructionCategory+mark.m}}</div>
                                </template>
                                <el-select @visible-change="visibleChange" v-model="Form.cbs_user.constructionCategory" slot="suffix"
                                           :placeholder="ContractorPersonnelDirectory.ConstructionCategory">
                                    <el-option label="请选择" value=""></el-option>
                                    <el-option v-for="item in ConstructionCategory" :label="item.value"
                                               :value="item.key">
                                    </el-option>
                                </el-select>
                            </el-input>
                            <span class="iputLineMust" v-if="!Form.cbs_user.constructionCategory">
                                <!-- 必填项添加 -->
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="11" :offset="2">
                    <div class="elst-select-mini">
                        <el-form-item prop="cbs_user.typeOfWork">
                            <el-input type="text" v-model="Form.cbs_user.typeOfWork" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{ContractorPersonnelDirectory.work+mark.m}}
                                </template>
                            </el-input>
                            <span class="iputLineMust" v-if="!Form.cbs_user.typeOfWork">
                                <!-- 必填项添加 -->
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <div class="el-input--mini el-input-group">
                                <div class="el-input-group__prepend">
                                    {{ContractorPersonnelDirectory.MainaAchievement+mark.m}}
                                </div>
                                <el-input class="el-textarea__inner" type="textarea" v-model="Form.cbs_user.mainaAchievement"
                                          autocomplete="off"></el-input>
                            </div>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>
            <el-row>
                <el-col class="head-tool">
                    <el-button type="primary" @click="UserInput('tj')">添加上岗证照</el-button>
                </el-col>
            </el-row>
            <el-row>
                <el-col span="24">
                    <el-table stripe :data="Form.cbs_user.cbS_UserAttachments" style="width: 100%">
                        <el-table-column prop="attachmentName" show-overflow-tooltip="true"
                                         :label="ContractorPersonnelDirectory.LicenseName">
                            <template slot-scope="scope">
                                <el-button type="text" @click="label_click(scope.row.attachmentId)">
                                    {{scope.row.attachmentName}}
                                </el-button>
                            </template>
                        </el-table-column>
                        <el-table-column prop="beginTime" :label="ContractorPersonnelDirectory.BeginTime":formatter="myformatDate"
                                         show-overflow-tooltip="true">
                        </el-table-column>
                        <el-table-column prop="endTime" :label="ContractorPersonnelDirectory.EndTime":formatter="myformatDate"
                                         show-overflow-tooltip="true">
                        </el-table-column>
                        <el-table-column prop="createTime" :label="ContractorPersonnelDirectory.EditorTime"
                                         show-overflow-tooltip="true">
                        </el-table-column>
                        <el-table-column label="操作">
                            <template slot-scope="scope">
                                <el-button @click.native.prevent="deleteRow(scope.$index, Form.cbS_UserAttachments)"
                                           type="text" size="small">
                                    移除
                                </el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-col>
            </el-row>


            <el-row type="flex" justify="end" style="margin-top:10px">
                <el-form-item>
                    <!--<el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnSave}}</el-button>-->
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnCommit}}</el-button>
                    <el-button type="primary" @click="onBack">{{col.btnBack}}</el-button>
                </el-form-item>
            </el-row>
        </el-form>
        <el-dialog :title="Title" :visible.sync="ListItem.dialogVisible" @close='closeDialog' width="80%" height="80%"
                   top="10vh" fullscreen="true">
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:95%;width:100%" frameborder="0"></iframe>
        </el-dialog>
    </div>
    <script type="text/javascript">

        var app = new Vue({
            el: '#app',
            data: {
                id: '',
                Title: '',
                //业务表单内容
                Form: {
                    cbs_user: {
                        id: guidEmpty,
                        personnelName: '',
                        sex: '',
                        birther: '',
                        phone: '',
                        cbsListId: '',
                        idNumber: '',
                        constructionCategory: '',
                        mainaAchievement: '',
                        Age: '',
                        TypeOfWork: '',
                        cbS_UserAttachments: []
                    }
                },
                ConstructionCategory: [],
                CheckProjectList: [],
                ListItem: ListItem,
                sex: [],
                CBS_List: [],
                //表单验证
                rules: {
                    'cbs_user.personnelName': [
                        verification.NotNull,
                        { pattern: verification.StringLengthAtoB.t.format(2, 5), message: verification.StringLengthAtoB.m.format(2, 5), trigger: 'blur' }
                    ],
                    'cbs_user.cbsListId': [
                        verification.NotNull
                    ],
                    'cbs_user.sex': [
                        verification.NotNull
                    ],
                    'cbs_user.birther': [
                        verification.NotNull
                    ],
                    'cbs_user.idNumber': [
                        verification.NotNull
                    ],
                    'cbs_user.phone': [
                        verification.NotNull
                    ],
                    'cbs_user.constructionCategory': [
                        verification.NotNull
                    ],
                    'cbs_user.typeOfWork': [
                        verification.NotNull
                    ],
                }
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                closeDialog: function () { closeDialog(this); },
                //点击表格中数据发生方法
                //label_click: function (val, id) { DialogShow(this, val, "ContractorPersonnelDirectoryManagementInputMineImg.html", id); },
                label_click: function (id) {
                    var path = downLoadPath(id)
                    location.href = path;
                },
                UserInput: function (val,id) {
                    this.Title = "上岗证照管理"
                    DialogShow(this, val, "ContractoEmploymentLicenseAdd.html", id);     
                },
                //提交数据
                onSubmitForm: function (formName) {
                    var mythis = this; 
                    this.$refs[formName].validate(function (valid) {
                        //验证通过
                        if (valid) {
                            onSubmitForm(this, '/api/CBS_User/Save', mythis.Form.cbs_user);
                        } else {
                            //验证失败
                            return false;
                        }
                    });
                },
                getData: function () {
                    getData(this, '/api/CBS_User/get?id=' + this.id);
                },
                ContractorInput: function (val, id) {
                    this.Title = "承包商列表"
                    DialogShow(this, val, "ContractorDirectoryList.html", id);
                },
                onBack: function () {
                    parent.app.ListItem.dialogVisible = false;
                },
                deleteRow: function (index, rows) {
                    rows.splice(index, 1);
                },
                //初始化承包商下拉框
                getCBS_List: function () {
                    var mythis = this;
                    myAjax("post", this, '/api/CBS_List/GetList', { model: { status: '01', IsBack: false, CreateFactory: null }, offset: 0, limit: 100 }, function (response) {
                        mythis.CBS_List = response.data.pageData;
                        console.log('h1', response.data.pageData);
                    }, false);
                },
            },
            mounted: function () {
                this.ConstructionCategory = getDicData('cbssglb');
                this.getCBS_List();
                this.sex = getDicData('001');
                this.id = getUrlParam("id");
                this.getData();
            }
        });
    </script>
</body>

</html>